package com.ruoyi.system.api;

import com.ruoyi.system.api.model.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import com.ruoyi.common.core.constant.SecurityConstants;
import com.ruoyi.common.core.constant.ServiceNameConstants;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.system.api.domain.SysUser;
import com.ruoyi.system.api.factory.RemoteUserFallbackFactory;

import java.util.List;

/**
 * 用户服务
 *
 * @author ruoyi
 */
@FeignClient(contextId = "remoteUserService", value = ServiceNameConstants.SYSTEM_SERVICE, fallbackFactory = RemoteUserFallbackFactory.class)
public interface RemoteUserService
{
    /**
     * 通过用户名查询用户信息
     *
     * @param username 用户名
     * @param source 请求来源
     * @return 结果
     */
    @GetMapping("/user/info/{username}")
    public R<LoginUser> getUserInfo(@PathVariable("username") String username, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 注册用户信息
     *
     * @param sysUser 用户信息
     * @param source 请求来源
     * @return 结果
     */
    @PostMapping("/user/register")
    public R<Boolean> registerUserInfo(@RequestBody SysUser sysUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 通过用户名查询用户信息
     *
     * @param username 用户名
     * @param source 请求来源
     * @return 结果
     */
    @GetMapping("/user/userinfo/{username}/{usertype}")
    public R<LoginUser> getUserUserInfo(@PathVariable("username") String username,@PathVariable("usertype") String usertype, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 通过shopcode,databasename查询databasecode.
     *
     * @param shopcode
     * @param databasename
     * @return ShopDatabase结果,取DatabaseCode
     */
    @GetMapping("/shopdatabase/shopdatabaseinfo/{shopcode}/{databasename}")
    public R<ShopDatabase> getShopDatabaseInfo(@PathVariable("shopcode") String shopcode, @PathVariable("databasename") String databasename, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 通过databasecode查询datasource属性
     *
     * @param databasecode
     * @return datasource属性
     */
    @GetMapping("/database/databaseinfo/{databasecode}")
    public R<ShopDatabaseProperty> getDatabasePropertyInfo(@PathVariable("databasecode") String databasecode, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 通过ShopCode查询UserShop属性
     *
     * @param shopCode
     * @return UserShop
     */
    @GetMapping("/shop/info/{shopCode}")
    public R<UserShop> getUserShopByShopCode(@PathVariable("shopCode") String shopCode, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @GetMapping("/user/getGroupUser/{userId}")
    public R<List<GroupUser>> getGroupUserByUserId(@PathVariable("userId") String userId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);


    @GetMapping("/user/getUserInfo/{userId}")
    public R<SysUser> getUserInfoByUserId(@PathVariable("userId") String userId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

}
